// bzoj3922
// 题意：给定一个数列，支持单调修改，询问，x0, x0+d, x0+2d, x0+3d...这个等差数列的最大值。
//
// 题解：当d很大时，暴力效率比较高，但是d很小时暴力效率低，所以考虑分块。
//       对d > k(d <= k)分块。小的时候，建立k系列个关于数列的树状数组，对于
//       第i个系列，讲整个数列关于%i划分，这样就可以建立%i个树状数组来连续
//       维护原来的等差数列。树状数组做rmq。
//       复杂度是O(m*( (n/k + log(n/d)) + (k*log^2(n/d)) )), 前一半是查询，后一半是修改。
//       这样可得理论最优分块大小为 k = sqrt(n) / log(n)。
//

// run: time $exec < input > output
// opt: 0
// flag: -g
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

int const maxn = 70007;
int da[maxn];
int n, m, piece;

std::vector<std::vector<std::vector<int> > > bit;

int lowbit(int x) { return x & (-x); }

void init()
{
	bit.resize(piece + 1);
	for (int i = 1; i <= piece; i++) {
		bit[i].resize(i);
		for (int j = 0; j < i; j++) bit[i][j].push_back(0);
		for (int j = 1; j <= n; j++) {
			int p = j % i;
			bit[i][p].push_back(da[j]);
			bit[i][p][0]++;
		}

		// init every remainder a bit
		for (int j = 0; j < i; j++) {
			for (int k = 1; k <= bit[i][j][0]; k++) {
				for (int t = 1; t < lowbit(k); t *= 2)
					bit[i][j][k] = std::max(bit[i][j][k], bit[i][j][k - t]);
			}
		}
	}
}

int reverse_map_index(int piece, int k, int re)
{
	return re + (k - (re != 0)) * piece;
}

int map_index(int p, int d, int re)
{
	return (p - re) / d + (re != 0);
}

void bit_update(int piece, int r, int p, int v)
{
	int n = bit[piece][r][0];
	bit[piece][r][p] = v;
//	std::cout << "n = " << n << " r = " << r << " p = " << p << " v = " << v << '\n';
	for (int i = p; i <= n; i += lowbit(i)) {
//		std::cout << "i = " << i << "   n = " << n << "    r = " << r << "  piece = " << piece << '\n';
		bit[piece][r][i] = da[reverse_map_index(piece, i, r)];
		for (int j = 1; j < lowbit(i); j *= 2)
			bit[piece][r][i] = std::max(bit[piece][r][i], bit[piece][r][i - j]);

		/*
		for (int ti = 1; ti <= bit[1][0][0]; ti++)
			std::cout << bit[1][0][ti] << ' ';
		std::cout << '\n';
		*/
	}
}

void update(int p, int v)
{
	da[p] += v;
	for (int i = 1; i <= piece; i++) {
		int r = p % i;
		int index = map_index(p, i, r);
		bit_update(i, r, index, da[p]);
	}
}

int bit_query_max_to_last(int piece, int re/*mainder*/, int l)
{
	int r = bit[piece][re][0];
	int ret = da[reverse_map_index(piece, r, re)];

	while (true) {
		ret = std::max(ret, da[reverse_map_index(piece, r, re)]);
		if (l == r) break;
		for (r--; r - l >= lowbit(r); r -= lowbit(r))
			ret = std::max(ret, bit[piece][re][r]);
	}
	return ret;
}

int query(int x0, int d)
{
	if (d > piece) {
		int ret = da[x0];
		for (int i = x0 + d; i <= n; i += d)
			ret = std::max(ret, da[i]);
		return ret;
	}
	int r = x0 % d;
	int p = map_index(x0, d, r);
	return bit_query_max_to_last(d, r, p);
}

int main()
{
	std::scanf("%d", &n);
	piece = std::sqrt(n) / (std::log(n)/std::log(2));
	for (int i = 1; i <= n; i++) std::scanf("%d", &da[i]);
	init();

	std::scanf("%d", &m);
	for (int i = 0, op; i < m; i++) {
		std::scanf("%d", &op);
		if (op == 0) {
			int p, v;
			std::scanf("%d %d", &p, &v);
			update(p, v);
		} else {
			int x0, d;
			std::scanf("%d %d", &x0, &d);
			std::printf("%d\n", query(x0, d));
		}
	}
}

